package com.yxjwzpx.management.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.yxjwzpx.management.domain.ShipOwner;
import com.yxjwzpx.management.service.IShipOwnerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 船家信息管理Controller
 * 
 * @author yxjwzpx
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/management/owner")
public class ShipOwnerController extends BaseController
{
    @Autowired
    private IShipOwnerService shipOwnerService;

    /**
     * 查询船家信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('management:owner:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShipOwner shipOwner)
    {
        startPage();
        List<ShipOwner> list = shipOwnerService.selectShipOwnerList(shipOwner);
        return getDataTable(list);
    }

    /**
     * 导出船家信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('management:owner:export')")
    @Log(title = "船家信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShipOwner shipOwner)
    {
        List<ShipOwner> list = shipOwnerService.selectShipOwnerList(shipOwner);
        ExcelUtil<ShipOwner> util = new ExcelUtil<ShipOwner>(ShipOwner.class);
        util.exportExcel(response, list, "船家信息管理数据");
    }

    /**
     * 获取船家信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:owner:query')")
    @GetMapping(value = "/{ownerId}")
    public AjaxResult getInfo(@PathVariable("ownerId") Long ownerId)
    {
        return success(shipOwnerService.selectShipOwnerByOwnerId(ownerId));
    }

    /**
     * 新增船家信息管理
     */
    @PreAuthorize("@ss.hasPermi('management:owner:add')")
    @Log(title = "船家信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShipOwner shipOwner)
    {
        return toAjax(shipOwnerService.insertShipOwner(shipOwner));
    }

    /**
     * 修改船家信息管理
     */
    @PreAuthorize("@ss.hasPermi('management:owner:edit')")
    @Log(title = "船家信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShipOwner shipOwner)
    {
        return toAjax(shipOwnerService.updateShipOwner(shipOwner));
    }

    /**
     * 删除船家信息管理
     */
    @PreAuthorize("@ss.hasPermi('management:owner:remove')")
    @Log(title = "船家信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ownerIds}")
    public AjaxResult remove(@PathVariable Long[] ownerIds)
    {
        return toAjax(shipOwnerService.deleteShipOwnerByOwnerIds(ownerIds));
    }
}
